
// 倒计时
export default function countDown(lefttime, intervalTime=1000, callback){
	let endTime = lefttime * 1000 + Date.now()
	let inter = setInterval(() => {	
	  lefttime = parseInt((endTime-Date.now()) / 1000);
	  // console.log('lefttime',lefttime)
	  var d = parseInt(lefttime / (24*60*60))
	  var h = parseInt(lefttime / (60 * 60) % 24);
	  var m = parseInt(lefttime / 60 % 60);
	  var s = parseInt(lefttime % 60);
	  let targetTime = {
		dd: d,
		hh: h < 10 ? '0' + h : h,
		MM: m < 10 ? '0' + m : m,
		ss: s < 10 ? '0' + s : s,
		status: lefttime > 0 
	  }
	  if(!targetTime.status) {
			clearInterval(inter)
	  }
	  callback(targetTime)			
	}, intervalTime);

	return inter
}